# Contributor:
# Maintainer: Fathi Boudra <fathi.boudra@linaro.org>
pkgname=supermin
pkgver=5.2.2
pkgrel=2
pkgdesc="tool for building supermin appliances"
url="https://libguestfs.org/"
arch="all !riscv64 !loongarch64" # limited by ocaml aport
license="GPL-2.0-or-later"
depends="cpio e2fsprogs"
makedepends="
	bash
	e2fsprogs-dev
	gawk
	ocaml
	ocaml-findlib
	perl
	"
subpackages="$pkgname-doc"
source="https://download.libguestfs.org/supermin/5.2-stable/supermin-$pkgver.tar.gz"
options="!check" # Disable tests as they fail under Alpine

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--disable-network-tests
	# https://bugs.alpinelinux.org/issues/10030
	# -no-pie is required to produce a statically linked init binary
	make -C init LDFLAGS="-no-pie"
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
c2a0758d6807155e226e0d9e460f8e72efbdb9d715ce7b22389dc3f4dbe34ff0d0c1afeb8e2852678602ba7ec3a700926b9c0078fc539765151b1f0167e01059  supermin-5.2.2.tar.gz
"
